<!DOCTYPE html>
<html xmlns:th="https://www.thymeleaf.org/">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>我的帐户</title>
    <link type="text/css" rel="stylesheet" th:href="@{css/index.css}"/>
    <link type="text/css" rel="stylesheet" th:href="@{css/bootstrap.min.css}"/>
    <script type="text/javascript" th:src="@{js/jquery-1.11.1.min.js}"></script>
    <script type="text/javascript" th:src="@{js/superslide.2.1.js}"></script>
    <script type="text/javascript" th:src="@{js/my.js}"></script>
    <script type="text/javascript" th:src="@{js/bootstrap.min.js}"></script>
    <script>
        $(document).ready(function () {
            $("#header").load("jump?url=common/header", null, function () {
                $(".nav_navs").children().eq(6).children().attr("class", "on")
                $(".header_h1").css("margin-top", "0px")
                $(".header_weixin").css("margin-top", "0px")
                $(".header_weixin>img").mouseover(function () {
                    $(".header_weixinBig").css('display', 'block');
                })
                $(".header_weixin>img").mouseout(function () {
                    $(".header_weixinBig").css('display', 'none');
                })
            })

            $("#banner0").load("jump?url=common/banner0", null, function () {
                let updateId = $("#userId").val();

                function getData() {
                    let dt = new Date();
                    // console.log(dt)
                    let dt2 = dt.getFullYear() + "-" + (dt.getMonth() + 1) + "-" + dt.getDate() + "  " + dt.getHours() + ":" + dt.getMinutes() + ":" + dt.getSeconds()
                    // console.log(dt2)
                    $("#time").html(dt2)
                }
                setInterval(getData,1000)

                $.ajax({
                    type: "POST",
                    url: "getResultById",
                    data: "updateId=" + updateId,
                    success: function (data) {
                        console.log(data)
                        if (data) {
                            $("#maxMoney").html(data)
                        }
                    }
                })
                $.ajax({
                    type: "POST",
                    url: "getMoneyById",
                    data: "updateId=" + updateId,
                    success: function (data) {
                        console.log(data)
                        if (data) {
                            $("#loanMoney").html(data)
                        }
                    }
                })
                $.ajax({
                    type: "POST",
                    url: "getOnlyMoney",
                    data: "updateId=" + updateId,
                    success: function (data) {
                        console.log('getOnlyMoney', data)
                        if (data >= 0) {
                            $("#onlyMoney").html(data)
                        } else {
                            alert("超过贷款上限！")
                        }
                    }
                })
                $.ajax({
                    type: "post",
                    url: "getIntegralById",
                    data: "updateId=" + updateId,
                    success: function (data) {
                        console.log(data)
                        if (data) {
                            $("#integral").html(data.rewardPoints)
                        }
                    },
                    error: function () {
                        alert("错误")
                    }
                })

                $.ajax({
                    type: 'get',
                    url: 'getPinMoneyByUserId',
                    success: function (data) {
                        console.log(data)
                        $("#pinMoney").text(data)
                    }
                })

                $("#setting").click(function () {
                    $("#updateModal").modal("show")
                    $.ajax({
                        type: "POST",
                        url: "queryUserById",   // queryUserById?updateId=updateId
                        data: {"updateId": updateId},
                        // data:"updateId="+updateId,
                        success: function (data) {
                            console.log(data)
                            if (data)
                                $("#userid").val(data.userId)
                            $("#userName").val(data.userName)
                            $("#address").val(data.address)
                            $("#industry").val(data.industry)

                            $("#birth").val(data.birth)
                            $("#tel").val(data.tel)
                            var dt = new Date(data.birth)
                            var d = dt.getFullYear() + "-" + (dt.getMonth() + 1) + "-" + dt.getDate()
                            $("#birth").val(d)
                            // $("#userimg1").attr('src',data.userimg)
                        },
                        error: function () {
                            alert("错误")
                        }
                    })
                })
                $("#save").click(function () {
                    let formData = new FormData($("#updateForm")[0]);
                    $.ajax({
                        type: "post",
                        url: "updateUserById",
                        data: formData,     //$("#updateForm").serialize()
                        contentType: false,
                        processData: false,
                        datatype: "Json",
                        success: function (data) {
                            if (data && data === "ok") {
                                $("#updateModal").modal("hide")
                                alert("信息保存成功!")
                                location.reload()
                            } else {
                                alert('保存失败!')
                            }
                        },
                        error: function () {
                            alert("错误")
                        }
                    })
                })
            })

            $("#tunav").load("jump?url=common/tunav", null, function () {
                $(".tunav").children().eq(0).children().addClass("active_nav")
                $(".tunav").children().eq(0).children().css("height", "102px")
                $(".xhx_line").children().eq(0).attr("class", "xhx_line_l")
                $(".xhx_line").children().eq(2).attr("class", "xhx_line_r")
            })

            $("#njmy").load("jump?url=common/njmy")

            $("#footer").load("jump?url=common/footer")
        })
    </script>
    <script type="text/javascript">

    </script>
</head>

<body>
<div id="header"></div>

<div id="banner0"></div>

<!--<div class="main">
    <div id="tunav"></div>
    <div></div>
</div>

<div id="njmy"></div>-->

<div style="margin-top: 70px;"></div>

<div id="footer"></div>

</body>
</html>
